<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/css/baStyle.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.11.0.min.js"></script>
<style type="text/css">


.searchBtn button,.searchTxt .searchMenu .searchSelected{background-image:url(../images/png/searchbg.png);background-repeat:no-repeat;}

.searchTxt{float:left;width:399px;height:30px;border:2px solid #d3d3d3;border-right:0;position:relative;z-index:20;background:#fff;}
.searchTxt .radius{width:1px;height:1px;overflow:hidden;background:#f4f4f4;position:absolute;top:-2px;left:-2px;}
.searchTxtHover{float:left;width:399px;height:30px;border:2px solid #3297d8;border-right:0;position:relative;z-index:20;background:#fff;}
.searchTxtHover .radius{width:1px;height:1px;overflow:hidden;background:#cce5f5;position:absolute;top:-2px;left:-2px;}

.searchTxt .searchMenu{float:left;}
.searchTxt .searchMenu .searchSelected{color:#a8a8a8;cursor:pointer;font-weight:bold;height:30px;line-height:30px;padding:0 5px;width:48px;background-position:0px -54px;}
.searchTxt .searchMenu .searchOpen{background-position:0px -104px;}

.searchTxt .searchMenu .searchTab{display:none; position:absolute;top:30px;left:-2px;width:58px;border:2px solid #3297d8;border-top:0;background:#fff;z-index:20;}
.searchTxt .searchMenu .searchTab li{width:58px;height:28px;line-height:28px;color:#a8a8a8;font-size:14px;font-weight:bold;text-indent:10px;cursor:pointer;background:0px;margin-left:0px;padding:0px;border:0px}
.searchTxt .searchMenu .searchTab li.selected{background:#edf3fc;color:#6994c1;}

.searchTxt input{float:left;border:0;background:#fff;color:#333;font:14px/22px '宋体',verdana,tahoma,arial,'SimSun',sans-serif;width:221px;height:22px;margin:0;outline:medium none;padding:4px;}

.searchBtn{float:left;}
.searchBtn button{background-position:0px 0px;border:0;color:#fff;cursor:pointer;float:left;font-size:16px;height:34px;text-indent:-9999px;width:86px;}
/* #searchBtn:hover{ background:#045270;} */


</style>
<script type="text/javascript">
//获取工程名称
$(document).ready(function(){
  /*复选框全选和全不选js*/
  $("#checkeds").click(function(){
      //下面的是用js的方式实现效果也是一样的 
        for(var i=0;i<$("#showTable :checkbox").length;i++){
         $("#showTable :checkbox")[i].checked=!$("#showTable :checkbox")[i].checked;
         }
  });
  
//给翻页指定页数样式
  $(".paginList a").each(function () {
     if("javascript:;"==$(this).attr("href")){
    	 $(this).parent("li").addClass("current");
     }
  });
  
 //搜索框的操作 
  $("#searchSelected").click(function(){ 
		$("#searchTab").show();
		$(this).addClass("searchOpen");
	}); 

	$("#searchTab li").hover(function(){
		$(this).addClass("selected");
	},function(){
		$(this).removeClass("selected");
	});
	 
	$("#searchTab li").click(function(){
		$("#searchSelected").html($(this).html());
		$("#searchTab").hide();
		$("#searchSelected").removeClass("searchOpen");
	});
  //给搜索框回显
	var _searchcolour ="${yearsType}";
	var _listYear ="${listYear}";
	if ("[]"!=_listYear) {
		$("#searchSelected").html(_searchcolour);
	}
	
	 //给搜索框回显
	var _searchVal ="${queryValue}";
	if (null!=_searchVal && ""!=_searchVal) {
		$('#searchValue').val(_searchVal);//给搜索框赋值
	}else{
		$('#searchValue').val("请输入搜索关键字");//给搜索框赋值
	}
	
});

//批量删除
function delectAll(rownum,year){
	var sum="";
	for(var i=0;i<$("#showTable :checkbox").length;i++){
		if($("#showTable :checkbox")[i].checked){
			var checkVal=$("#showTable :checkbox")[i].value;
			if(""==sum){
				sum+=checkVal;
			}else{
				sum+=","+checkVal;
			}
		}
     }
	if(""!=sum){
	 var r=confirm("确定删除！");
	   if (r==true){
				$.ajax({
					type:"post", //提交的类型
					url:"${pageContext.request.contextPath}/draws/delectAll.do",//提交地址
					data: {
					    "uuid":sum,
					   },
					dataType: 'text',
					success: function(data){ //回调方法
						if('succeed'==data){
							alert("删除成功！");
							location='${pageContext.request.contextPath}/draws/drawBasic.do?currentPageNumber='+rownum+'&year='+year+'&queryValue=${queryValue}';
							refresh(year);//刷新重新生成模板
						}else{
							alert("删除失败！");
						}
					}
					});
	       }
	}else{
		alert("请选择至少一条要删除的数据！");
	}
}

//删除单条信息
function delectAlone(id,rownum,year){
	var r=confirm("确定删除！");
	if (r==true){
		$.ajax({
			type:"post", //提交的类型
			url:"${pageContext.request.contextPath}/draws/delectAlone.do",//提交地址
			data: {
			    "uuid":id
			   },
			dataType: 'text',
			success: function(data){ //回调方法
				if('succeed'==data){
					alert("删除成功！");
					location='${pageContext.request.contextPath}/draws/drawBasic.do?currentPageNumber='+rownum+'&year='+year+'&queryValue=${queryValue}';
					refresh(year);//刷新重新生成模板
				}else{
					alert("删除失败！");
				}
			}
			});
	  }	
}

		
//搜索数据
var opinionObj = false;
function searchQuery(){
	var year=$('#searchSelected').html();
	var inputval=$('#searchValue').val();
	if("请输入搜索关键字"!=inputval){
		var searchFormObj = $("#searchPicForm");
		if(!opinionObj){
			searchFormObj.append(getHiddenObj("searyear","year",year));
			searchFormObj.append(getHiddenObj("queryValue","queryValue",inputval));
			opinionObj = true;
		}	
		searchFormObj.submit();	
	}else{
		alert("请输入要查询的数据！");
	}
	 
}


//页面右上角选择图片类型
var hasAppendPageObj = false;
function thumpicQuery(year){
	var searchFormObj = $("#thumpicForm");
	if(!hasAppendPageObj){
		searchFormObj.append(getHiddenObj("year","year",year));
		hasAppendPageObj = true;
	}	
	searchFormObj.submit();
}
function getHiddenObj(objId,objName,objValue){
	return jQuery("<input type=\"hidden\" id=\""+objId+"\" name=\""+objName+"\" value=\""+objValue+"\" />");
}

function refreshLoad(year,rownum){
	location='${pageContext.request.contextPath}/draws/drawBasic.do?currentPageNumber='+rownum+'&year='+year;
	refresh(year);
}

//刷新使用，会将数据重新生成一遍
function refresh(year){
	$.ajax({
		type:"post", //提交的类型
		url: "${pageContext.request.contextPath}/draws/returnRefresh.do",//提交地址
		data: {
		    "year":year,
		   },
		dataType: 'text',
		success: function(data){ //回调方法
			/* if('succeed'==data){
				alert("删除成功！");
			}else{
				alert("删除失败！");
			} */
		}
		});
}    

//清空数据
function clearData(year){
	if("[]"!="${listYear}"){
	var r=confirm("请慎用该操作,确定要清空["+year+"]年的数据！");
	if (r==true){
		$.ajax({
			type:"post", //提交的类型
			url:"${pageContext.request.contextPath}/draws/clearData.do",//提交地址
			data: {
			    "year":year
			   },
			dataType: 'text',
			success: function(data){ //回调方法
				if('0'!=data){
					alert("数据成功！");
					location='${pageContext.request.contextPath}/draws/drawBasic.do';
				}else{
					alert("删除失败！");
				}
			}
			});
	  }	
	}else{
		alert("暂无数据可清空！");
	}
}

</script>

</head>
<body>
<!--图片类型选择  -->
<form id="thumpicForm" action="${pageContext.request.contextPath}/draws/drawBasic.do" method="post"></form>
<!--搜索  -->
<form id="searchPicForm" action="${pageContext.request.contextPath}/draws/drawBasic.do" method="post"></form>
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">首页</a></li>
			<li><a href="#">图纸基本操作</a></li>
		</ul>
	</div>
	<div class="rightinfo">
		<div class="tools">
			<ul class="toolbar">
				<li onclick="window.top.addDrawDate(${yearsType});"><span><img
						src="${pageContext.request.contextPath}/images/baImages/t01.png" /></span>新增信息</li>
				<li onclick="delectAll('${currentPage}','${yearsType}');"><span><img
						src="${pageContext.request.contextPath}/images/baImages/t03.png" /></span>批量删除</li>
						
				<li onclick="clearData('${yearsType}');"><span><img
						src="${pageContext.request.contextPath}/images/baImages/t03.png" /></span>清空数据</li>
				<%-- <li class="click"><span><img src="${pageContext.request.contextPath}/images/baImages/t02.png" /></span>选择</li> --%>
			</ul>
			<ul class="toolbar1">
			   <li class="selectList" style="background:0px;border:0px">
					<%-- <form method="post" class="search" action="${pageContext.request.contextPath}/baSkip/searchPic.do"> --%>
						<div id="searchTxt" class="searchTxt"
							onMouseOver="this.className='searchTxt searchTxtHover';"
							onMouseOut="this.className='searchTxt';">
							<div class="radius" style="top: -2px;"></div>
							<div class="radius" style="top: 31px;"></div>
							<div class="searchMenu">
								<div class="searchSelected" id="searchSelected">请选择</div>
								<div style="display: none;" class="searchTab" id="searchTab">
									<div class="radius" style="top: 259px;"></div>
									<div class="radius" style="top: 259px; left: 59px;"></div>
									<ul>
										<c:forEach items="${listYear}" var="brand">
						                    <li>${brand}</li>
					                    </c:forEach>
									</ul>
								</div>
							</div>
							<input name="w" type="text" id="searchValue"
								onkeydown="javascript:if(event.keyCode==13) search('key');"
								onblur="if (this.value==''){this.value=this.defaultValue;this.style.color='#999'}"
								onfocus="if (this.value==this.defaultValue){this.value='';this.style.color='#333'}"
								value="请输入搜索关键字"/>
						</div>
						<div class="searchBtn">
							<button id="searchBtn" type="submit" onclick="searchQuery();">搜索</button>
						</div>
					<!-- </form> -->
                 </li>
			
				<li class="selectList" >
					<span>选择查看年份
					<select name="type"id="type" onchange="javascript:thumpicQuery(this.value);"
							style="width: 90px; border:1px solid #3994c7; text-indent: 0; background: #f2f2f2;position: relative; bottom: -1px;">
								<option class="selects" selected="selected" value="">请选择</option>
								<c:forEach items="${listYear}" var="brand">
								   		<option class="selects" value="${brand}">${brand}</option>
					            </c:forEach>
						</select>
					</span> 
					<!-- <span>
					<button class="thumpic" type="button" onclick="thumpicQuery();">查询
					</button>
					</span> -->
				</li>
			</ul>
		</div>
		<table class="tablelist">
			<thead>
				<tr>
					<th><input id="checkeds" name="" type="checkbox" value="" /></th>
					<th>名称<i class="sort"><img src="${pageContext.request.contextPath}/images/baImages/px.gif" /></i></th>
					<th>中文名称</th>
					<th>年份</th>
					<th>图片地址</th>
					<th>页面地址</th>
					<th>排序</th>
					<th>审核状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="showTable">

				<c:forEach items="${datas}" var="brand">
					<tr>
						<td style="display: none;"><input name="" type="hidden"
							value="${brand.id}" /></td>
						<td><input name="checkbox" type="checkbox" value="${brand.id}" /></td>
						<td>${brand.picname}</td>
						<td>${brand.desctibe}</td>
						<td>${brand.year}</td>
						<td>${brand.urladdress}</td>
						<td>${brand.htmlAddress}</td>
						<td>${brand.featureSort}</td>
						<td>已审核</td>
						<td><a href="#" class="tablelink" onclick="window.top.updateDraw('${baUrl}${draUrl}','${brand.id}','${brand.picname}','${brand.desctibe}','${brand.year}','${brand.featureSort}',${currentPage})">编辑</a> 
						    <a href="#" class="tablelink" onclick="delectAlone('${brand.id}','${currentPage}','${yearsType}')">删除</a>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<div class="pagin">
			<div class="message">
				共<i class="blue">${rowCount}</i>条记录，总页数<i class="blue">${pageCount}</i>，当前显示第&nbsp;<i
					class="blue">${currentPage}&nbsp;</i>页
			</div>
			<ul class="paginList">
				<li class="paginItem"><a
					href="<c:url value='/draws/drawBasic.do?currentPageNumber=1&year=${yearsType}&queryValue=${queryValue}'/>">首页</a></li>
				<li class="paginItem"><c:if test="${currentPage!=1}">
						<a
							href="<c:url value='/draws/drawBasic.do?currentPageNumber=${currentPage-1}&year=${yearsType}&queryValue=${queryValue}'/>">
							<span class="pagepre"></span>
						</a>
					</c:if></li>
				<c:forEach begin="${showStart}" end="${showEnd}" var="page">
					<c:if test="${currentPage==page}" var="boo">
						<li class="paginItem"><a href="javascript:;">${page}</a></li>
					</c:if>
					<c:if test="${!boo}">
						<li class="paginItem"><a
							href="<c:url value='/draws/drawBasic.do?currentPageNumber=${page}&year=${yearsType}&queryValue=${queryValue}'/>">
								${page} </a></li>
					</c:if>
				</c:forEach>
				<li class="paginItem"><c:if test="${currentPage!=pageCount}">
						<a
							href="<c:url value='/draws/drawBasic.do?currentPageNumber=${currentPage+1}&year=${yearsType}&queryValue=${queryValue}'/>">
							<span class="pagenxt"></span>
						</a>
					</c:if></li>
				<li class="paginItem"><a
					href="<c:url value='/draws/drawBasic.do?currentPageNumber=${pageCount}&year=${yearsType}&queryValue=${queryValue}'/>">尾页</a>
				</li>
			</ul>
		</div>
	</div>
	<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>
</body>
</html>
